from script.server.teleweb.HttpTelewebServer import HttpTelewebServer


class T2mShServer(HttpTelewebServer):
    NAME = 'T2M-SH'

    # _host: str = 'https://t2mteleweb.tcl-ta.com/SECURITY/LIVRAISON_BF'
    _host: str = 'https://172.31.3.12/SECURITY/LIVRAISON_BF'
    _username: str = 'telet2m'
    _password: str = 'Tlwoj65!'
    _PATTERN_FILE_LINE = r'(<tr><td\s.+</td></tr>)'
    _PATTERN_FILE_INFO =\
        r'.*<img\s.*alt="\[(.+)\]".*>.*<a\s.*href="(.+)".*>.*</a>\s*</td>' \
        r'<td align="right">([^<]+)</td>.*?>([^<]+)</td>.*'

    def __init__(self):
        super(T2mShServer, self).__init__(T2mShServer._host,
                                          T2mShServer._PATTERN_FILE_LINE, T2mShServer._PATTERN_FILE_INFO,
                                          T2mShServer._username, T2mShServer._password)

    def name(self) -> str:
        return T2mShServer.NAME
